<template>
  <h3>这是我的页</h3>
  <p>name: {{ name }}</p>
  <button @click="fn">btn</button>
  <ul>
    <li v-for="item in list" :key="item.id">{{ item.nm }}</li>
  </ul>
</template>

<script>
import { mapActions } from "vuex";

export default {
  computed: {
    name() {
      return this.$store.state.module1.name;
    },
    list() {
      return this.$store.state.module1.list;
    },
  },
  methods: {
    fn() {
      // 调用仓库里面的actions里的changeName2
      // actions里的changeName2去调用mutations里的changeName
      // 从而改变仓库的数据
      // this.$store.dispatch("changeName2", "wangwu");
      this.changeName2("wangwu");
    },
    ...mapActions(["changeName2"]),
  },
};
</script>
